home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Science / RLaB / help / OPERATORS < prev    next >
Text File  |  1994-04-25  |  6KB  |  200 lines

  1. OPERATORS:
  2.  
  3.     DEFINITION: An operator is a symbol(s) that takes operand(s)
  4.     as input, and computes a result(s) that is a function of the
  5.     operand(s).
  6.  
  7.     We can draw an analogy between operators and functions. The
  8.     operands are analogous to a functions arguments, and the
  9.     operation result is analogous to the functions return
  10.     value(s). Any symbol that does not fit this definition of an
  11.     operator is a delimiter. For example: the semi-colon, `;' is
  12.     NOT an operator. A user cannot use the semi-colon to generate
  13.     a tangible result.
  14.  
  15.     Relational and logical operators are discussed in the
  16.     help-file `RELATIONAL' (see `help RELATIONAL').
  17.  
  18.     Valid unary operators (operators that operate on a SINGLE object)
  19.  
  20.     +    unary plus
  21.     -    unary minus
  22.     ++    increment
  23.     --    decrement
  24.     '    MATRIX transpose
  25.  
  26.     Note: the increment and decrement operators are NOT exactly
  27.     like the C post-increment and post-decrement. RLaB inc/decs
  28.     the value of the variable immediately.
  29.  
  30.     Valid binary operators (operate on two objects)
  31.  
  32.     +    addition
  33.     .+    addition (el-by-el)
  34.     -    subtraction
  35.     .-    subtraction (el-by-el)
  36.     *    multiplication
  37.     .*    multiplication (el-by-el)
  38.     /    right division            (see DIVISION)
  39.     ./    el-by-el right division        (see DIVISION)
  40.     \    left division            (see DIVISION)
  41.     .\    el-by-el left division        (see DIVISION)
  42.     ^    power
  43.     .^    el-by-el power
  44.  
  45.     The binary operators are supposed to function like their
  46.     MATLAB counterparts. However, there are a few extensions, for
  47.     more details - see below.
  48.  
  49.     Following are the rules used for applying the binary operators.
  50.  
  51.     Miscellaneous (but very important) operators.
  52.  
  53.     ,    concatenation (inside `[' `]' only)
  54.     :    vector construction
  55.     [ ]    matrix construction, and MATRIX element reference.
  56.  
  57.     The `:' operator is used to build vectors (a 1xN matrix) with
  58.     regular intervals (default interval = 1).
  59.  
  60.     > 1:10
  61.  
  62.     builds the vector `1,2,3,4,5,6,7,8,9,10'
  63.  
  64.     > 1:2:.5
  65.  
  66.     builds the vector `1,1.5,2'
  67.  
  68.     This 1st operand is the vector start value, the 2nd operand is
  69.     the vector end value, and the 3rd operand is the vector
  70.     increment. 
  71.  
  72.     The `;' is the RLaB separator. In some ways it acts as a
  73.     vertical append operator, but since it is not accessible to
  74.     users as an explicit operator, it is a delimiter.
  75.  
  76.     The `[' and `]' serve a dual function. The first is to serve
  77.     as the MATRIX construction operators. Enclose an expression
  78.     with `[' and `]' and RLaB will try and make a MATRIX out of
  79.     the expression.
  80.  
  81.     The second function of `[' and `]' is to serve as the MATRIX
  82.     element reference operators, thus:
  83.  
  84.     > m=[1,2,3;4,5,6;7,8,9]
  85.      m =
  86.      matrix columns 1 thru 3
  87.                1           2           3
  88.                4           5           6
  89.                7           8           9
  90.  
  91.     builds a matrix, and assigns it to `m'. To reference the
  92.     element in the 2nd row, and 2nd column:
  93.  
  94.     > m[2;2]
  95.                5
  96.  
  97.     Reference the 2-by-2 sub-matrix formed by extracting the 1st
  98.     and 2nd rows, and switching the 2nd and 1st columns.
  99.  
  100.     > m[1,2;2,1]
  101.      matrix columns 1 thru 2
  102.                2           1
  103.                5           4
  104.  
  105.     ----------------------------------------------------------------
  106.  
  107.     Element-by-element multiplication (.*): This operator
  108.     multiplies two matrices together in a manner deteremined by
  109.     the operands dimensions. For C = A.*B:
  110.  
  111.     A (MxN), B (MxN), C (MxN): C is the element-by-element product
  112.     of A and B.
  113.  
  114.     A (1x1), B (MxN), C (MxN): C is the product of A and each
  115.     element in B.
  116.  
  117.     A (MxN), B (1x1), C (MxN): C is the product of B and each
  118.     element in A.
  119.  
  120.     A (0x0), B (MxN), C (0x0): C is the NULL matrix.
  121.     A (MxN), B (0x0), C (0x0): C is the NULL matrix.
  122.  
  123.     A (1xN), B (MxN), C (MxN): C is the element-by-element product
  124.     of A with each row of B.
  125.  
  126.     A (Mx1), B (MxN), C (MxN): C is the element-by-element product
  127.     of A with each column of B.
  128.  
  129.     A (MxN), B (1xN), C (MxN): C is the element-by-element product
  130.     of B with each row of A.
  131.  
  132.     A (MxN), B (Mx1), C (MxN): C is the element-by-element product
  133.     of B with each column of A.
  134.     
  135.     ----------------------------------------------------------------
  136.  
  137.     Element-by-element division (./): This operator divides two
  138.     matrices together in a manner deteremined by the operands
  139.     dimensions. For C = A./B:
  140.  
  141.     A (MxN), B (MxN), C (MxN): C is the result of
  142.     element-by-element division of A and B.
  143.  
  144.     A (1x1), B (MxN), C (MxN): C is the result of division of each
  145.     element of B by A. 
  146.  
  147.     A (MxN), B (1x1), C (MxN): C is the result of division of each
  148.     element of A by B.
  149.  
  150.     A (0x0), B (MxN), C (0x0): C is the NULL matrix.
  151.     A (MxN), B (0x0), C (0x0): C is the NULL matrix.
  152.  
  153.     A (1xN), B (MxN), C (MxN): C is the result of
  154.     element-by-element division of A with each row of B.
  155.  
  156.     A (Mx1), B (MxN), C (MxN): C is the result of
  157.     element-by-element division of A with each column of B.
  158.  
  159.     A (MxN), B (1xN), C (MxN): C is the result of
  160.     element-by-element division of each row of A with B.
  161.  
  162.     A (MxN), B (Mx1), C (MxN): C is the result of
  163.     element-by-element division of each column of B with A.
  164.  
  165.     ----------------------------------------------------------------
  166.     
  167.     Addition is always an element-by-element operation, however
  168.     the operand sizes must match. For cases where the operand
  169.     sizes do not match (intentionally) the `.+' operator is
  170.     supplied.  The result is determined by the size of each
  171.     operand, for C = A .+ B:
  172.  
  173.     A (MxN), B (MxN), C (MxN): C is the result of
  174.     element-by-element addition of A and B.
  175.  
  176.     A (1x1), B (MxN), C (MxN): C is the result of
  177.     element-by-element addition of A and each element of B.
  178.  
  179.     A (MxN), B (1x1), C (MxN): C is the result of
  180.     element-by-element additiion of each element of A and B.
  181.  
  182.     A (0x0), B (MxN), C (0x0): C is the NULL matrix.
  183.     A (MxN), B (0x0), C (0x0): C is the NULL matrix.
  184.  
  185.     A (1xN), B (MxN), C (MxN): C is the result of
  186.     element-by-element addition of A and each row of B.
  187.  
  188.     A (Mx1), B (MxN), C (MxN): C is the result of
  189.     element-by-element addition of A and each column of B.
  190.  
  191.     A (MxN), B (1xN), C (MxN): C is the result of
  192.     element-by-element addition of B and each row of A.
  193.  
  194.     A (MxN), B (Mx1), C (MxN): C is the result of
  195.     element-by-element addition of B and each column of A.
  196.  
  197.     ----------------------------------------------------------------
  198.     Subtractin follows the same dimensional rules as addition.    
  199.     ----------------------------------------------------------------
  200.